GAL-GEM is a complete machine emulator for the GAL (Generic Assembly Language) and GEM (GEneric Machine) computation models, as described in “Computer organization: a top down approach” by Greg W. Scragg (referred to as ‘CO’ throughout this document).
“Computer Organization: a top down approach” focuses on assembly language at the conceptual level, relatively free of the restrictions of real assembly languages, and illustrates important concepts through a Generic Assembly Language: GAL. Many readers have requested software that supports that language and provides students with hands on experience. In response, I have created a full emulator for the GAL language and the corresponding GEneric Machine, GEM.
GEM 1.0 accepts GAL assembly language programs, assembles and runs them on its CPU emulator. It displays continuously updated information about the current state of the program, allowing students to follow the execution at the machine level This display includes:
* original GAL source code
* GEM machine language code
* cross referencing between the two sets of codes
* all data registers
* major system registers, including PC, IR, MAR, MBR, and CC.
* output window for user program output
* all referenced RAM locations
* highlighting of current instruction in both machine and assembly language windows
The assembler accepts the full GAL language. The emulation can be run at a reduced speed for ease of following the execution. Instructions can be executed singly, or even a single cycle at a time. The user can choose between binary, decimal or hexadecimal representation of the registers. The PC can be reset, allowing repeated execution without reloading or reassembling. Simple I/O tools eliminate many of the I/O roadblocks to beginning assembly or organization students. All windows are scrollable, allowing easy use with longer programs (or smaller displays),
--------------------------- Basic operation of the emulator ---------------------------
Machine and system requirements:
GAL-GEM will run on any Mac running system 7.0 or later with 128K of available RAM,
The basic steps for using GAL-GEM are:
Open a GAL language program.
Assemble the program.
Run the program.
----------------------------- Menu commands -----------------------------
File menu
Open : opens and displays a single assembly language file.
Quit: terminates the emulator.
GAL&GEM Menu:
Assemble: Assembles and loads the currently open GAL file. The PC is italicized to the first instruction of object file.
Run: starts execution at the address currently pointed to by the PC. Normally execution continues until a halt instruction or an execution error is encountered, In step or cycle mode, only a single step or cycle executes.
Reset: reinitializes the PC and clears the output window, enabling the user to rerun a program without reassembling.
Step and cycle mode: Stepmode executes exactly one instruction per run command, serving as a useful debugging tool. Cyclemode executes one fetch or execute cycle per instruction and is useful for understanding the fetch-execute cycle. Note that one cycle is treated as a fetch or execute step -- not as one bus cycle. All operands are fetched in a single fetch step.
Slowmode: slows GEM down to approximately 1 instruction per second for following the execution flow.
Tracing: With tracing turned off, programs will execute at many times their normal speed but no trace of the execution is displayed. When execution is complete, all registers are updated. Changes to RAM are recorded but not highlighted. This feature is useful when you are only interested in the final result and do not care about the steps.
Binary, decimal and Hexadecimal: select the radix for register display.
I/O handshaking: turns on input handshaking as described in the I/O section below.
View menu
Bring any window display window to the front, or toggle the control panel between visible and invisible.
---------------------------- Control Panel ----------------------------
The control panel duplicates the menu commands needed for basic operation of the emulator: load (open), assemble, run, reset and exit.
---------------------------- GAL Syntax ----------------------------
The emulator is faithful to the description of the GAL language in Chapters 2 and 5 of ‘CO.’ Exceptions are:
Arrows:
GAL uses single and double shafted arrows to separate operands. Since most standard keyboards do not have arrows, GAL allows any of the follow as delimiters:
=> (equal-arrow)
-> (minus arrow)
, (comma)
Although the single and double shafted arrows are used for distinct purposes in GAL, the emulator does not punish the user for misuse.
In addition to code, the assembler allows blank lines, comment only lines and lines containing only a label..
The sample programs include a file containing GAL version of all subroutines referenced in ‘CO,’ including ‘input’ and ‘output.’ Users may include them them in their own programs.
-----------------------------Writing GAL program files-----------------------------
Input for the GAL emulator can be any text-only file, created with any word or text processor. The word processor file may be left open while running the emulator, for ease in debugging.
If possible set, tab stops on the word processor to every three columns. This will make consistent alignment easier in the assembly language window.
During execution of a user program, the host machine’s keyboard serves as the input device for the GEM machine. Keyboard input (except control characters) are passed directly to the emulator. Control characters are intercepted and cannot be used as input to the emulated program.
Input is unbuffered. That will result in lost input if the user types more than one character ahead of the user program’s attempts to read.
Handshaking:
GEM has optionally hardware handshaking for input. With handshaking enabled (default), any attempt by the user program to read input when none is available will cause the CPU to wait for input. With handshaking enabled, the user programs need not check the status of the input port. With handshaking turned off, the user program can implement software handshaking as described in Chapter 12 of ‘CO.’ Output buffering causes no problems with or without handshaking.
I/O ports:
GEM uses memory addresses 0-3 as I/O ports as follows:
address use name
0 input status byte inputstatus
1 input data byte inputdata
2 output status byte outputstatus
3 output data byte outputdata
The user program should not use these addresses for other purposes. The names of those locations are pre-declared and should not be declared by the user program.
GAL-GEM is shareware -- however it is available free to its intended audience: users of “Computer Organization: a top-down approach” by Greg Scragg. I ask only that you send me a message (Email, snailmail, whatever) saying that you are using it (comments, complaints, requests, etc. are, of course, welcome).
For other users, the shareware price is $15 for a single copy or $100 for a site license. Exploration and testing, are, of course, free. No permission is granted for any commercial purposes.